CREATE TABLE [dbo].[UserAccount]
(
[Id] [int] NOT NULL IDENTITY(1, 1),
[Username] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Title] [nvarchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[FirstName] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[LastName] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Password] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[PasswordSalt] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[LastLogin] [datetime] NULL,
[UserType] [int] NOT NULL,
[CreatedDate] [datetime] NULL CONSTRAINT [DF_UserAccount_CreatedDate] DEFAULT (getdate()),
[UpdatedDate] [datetime] NULL CONSTRAINT [DF_UserAccount_UpdatedDate] DEFAULT (getdate()),
[CreatedUser] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[UpdatedUser] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[IsActivity] [bit] NOT NULL CONSTRAINT [DF_UserAccount_IsActivity] DEFAULT ((1))
) ON [PRIMARY]
CREATE UNIQUE NONCLUSTERED INDEX [IX_UserAccount] ON [dbo].[UserAccount] ([Username]) ON [PRIMARY]

ALTER TABLE [dbo].[UserAccount] ADD 
CONSTRAINT [PK_UserAccount] PRIMARY KEY CLUSTERED  ([Id]) ON [PRIMARY]
ALTER TABLE [dbo].[UserAccount] ADD
CONSTRAINT [FK_UserAccount_UserType] FOREIGN KEY ([UserType]) REFERENCES [dbo].[UserType] ([Id])
GO

EXEC sp_addextendedproperty N'MS_Description', N'Mã để mã hóa password', 'SCHEMA', N'dbo', 'TABLE', N'UserAccount', 'COLUMN', N'PasswordSalt'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Mã để mã hóa password', 'SCHEMA', N'dbo', 'TABLE', N'UserAccount', 'COLUMN', N'UserType'
GO
